package com.gewu.pm.ui.fragment;

import androidx.viewpager.widget.ViewPager;

import com.androidkun.xtablayout.XTabLayout;
import com.gewu.pm.R;
import com.gewu.pm.app.AppFragment;
import com.gewu.pm.app.TitleBarFragment;
import com.gewu.pm.ui.MainActivity;
import com.gewu.pm.ui.fragment.message.PendingWorkFragment;
import com.gewu.pm.ui.fragment.message.SystemNotificationFragment;
import com.hjq.base.FragmentPagerAdapter;

/**
 *  消息 Fragment
 */
public final class MessageFragment extends TitleBarFragment<MainActivity> {

    private XTabLayout mTabLayout;
    private ViewPager mViewPager;
    private FragmentPagerAdapter<AppFragment<?>> mPagerAdapter;

    public static MessageFragment newInstance() {
        return new MessageFragment();
    }

    @Override
    protected int getLayoutId() {
        return R.layout.message_fragment;
    }

    @Override
    protected void initView() {
        mTabLayout = findViewById(R.id.tab_layout);
        mViewPager = findViewById(R.id.vp_content);

        // 创建 FragmentPagerAdapter
        mPagerAdapter = new FragmentPagerAdapter<>(this);
        
        // 添加 Fragment
        mPagerAdapter.addFragment(SystemNotificationFragment.newInstance(), getString(R.string.system_notification));
        mPagerAdapter.addFragment(PendingWorkFragment.newInstance(), getString(R.string.pending_work));
        
        // 设置 Adapter
        mViewPager.setAdapter(mPagerAdapter);
        
        // 关联 TabLayout 和 ViewPager
        mTabLayout.setupWithViewPager(mViewPager);
    }

    @Override
    protected void initData() {

    }

    @Override
    public boolean isStatusBarEnabled() {
        // 使用沉浸式状态栏
        return !super.isStatusBarEnabled();
    }

}